import 'package:eplorex/models/contact/contact_model.dart';
import 'package:eplorex/utils/HttpUtil.dart';

class UserContactDao {
  static Future<List<ContactModel>?> queryUserContactFriends() async {
    var response =
        await HttpUtil.getInstance().get("/api/user/v1/contact/friend");
    if (response!.statusCode == 200 && response.data != null) {
      return (response.data['data'] as List)
          .map((e) => ContactModel.fromJson(e))
          .toList();
    } else {
      return null;
    }
  }

  static Future<List<ContactModel>?> queryUserContactNewFriends() async {
    var response =
        await HttpUtil.getInstance().get("/api/user/v1/contact/new/friend");

    if (response!.statusCode == 200) {
      return (response.data['data'] as List)
          .map((e) => ContactModel.fromJson(e))
          .toList();
    } else {
      return null;
    }
  }

  static Future<List<ContactModel>?> queryUserContactGroup() async {
    var response =
        await HttpUtil.getInstance().get("/api/user/v1/contact/group");

    if (response!.statusCode == 200) {
      return (response.data['data'] as List)
          .map((e) => ContactModel.fromJson(e))
          .toList();
    } else {
      return null;
    }
  }
}
